<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use DB;

class Official extends Model
{
    protected $dateFormat = 'U';
    //
    protected $table = "lexiang_official_editor";
    protected $primaryKey = 'official_id';
    public function edit($data)
    {
    	DB::beginTransaction();
    	foreach ($data as $key => $value) {
    		$that = $this->where('field_name',$key)->first();
    		$that->value = $value;
    		if(!$that->save()){
    			DB::rollBack();
    			return [
    				'success'=>false,
    				'code'=>'006',
    				'message'=>'修改出错，请稍后再试！'
    			];
    		}

    	}
    	DB::commit();
    	return [
    		'success'=>true,
    		'code'=>'000',
    		'message'=>'修改成功'
    	];
    }
}
